<?php
/**
 * Created by PhpStorm.
 * Author: yostar
 * User: THINK
 * Date: 2018/6/5
 * Time: 9:47
 */

namespace wechat\model;

require_once 'Common.php';

class CustomerService extends Common
{
    public function addAccount($data)
    {
        $url = $this->formatUrlWithToken($this->wechat_config['addCustomerServiceAccountUrl']);
        $result = $this->curl_post($data, $url);
        if (isset($result['errcode']) && $result['errcode'] == 0) {
            return true;
        } else {
            return false;
        }
    }

    public function updateAccount($data)
    {
        $url = $this->formatUrlWithToken($this->wechat_config['updateCustomerServiceAccountUrl']);
        $result = $this->curl_post($url, $data);
        if ($result['errcode'] == 0) {
            return true;
        } else {
            return false;
        }
    }

    public function getList()
    {
        $url = $this->formatUrlWithToken($this->wechat_config['getCustomerServiceListUrl']);
        $result = $this->curl_get($url);
        if (isset($result['kf_list'])) {
            return $result;
        } else {
            return false;
        }
    }

    public function deleteAccount()
    {
        $url = $this->formatUrlWithToken($this->wechat_config['deleteCustomerServiceAccountUrl']);
        $result = $this->curl_get($url);
        var_dump($result);
    }
}